package com.bcu.calculus.service.serviceImpl;

import com.bcu.calculus.entity.CheckType;
import com.bcu.calculus.entity.Message;
import com.bcu.calculus.mapper.CheckTypeMapper;
import com.bcu.calculus.service.CheckTypeService;
import com.bcu.calculus.utils.SendUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class CheckTypeServiceImpl implements CheckTypeService {

    @Resource
    private CheckTypeMapper checkTypeMapper;


    @Override
    public Message<?> insertSelective(CheckType checkType) {
        String CTID = "CT" + SendUtil.genSendId();
        checkType.setCheckTypeId(CTID);
        return checkTypeMapper.insertSelective(checkType)> 0 ? Message.success(null).add(CTID) : Message.fail(null);
    }

    @Override
    public Message<?> deleteByPrimaryKey(String checkTypeId) {
        return checkTypeMapper.deleteByPrimaryKey(checkTypeId)> 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<?> updateByPrimaryKeySelective(CheckType checkType) {
        return checkTypeMapper.updateByPrimaryKeySelective(checkType)> 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message<List<CheckType>> selectAll() {
        return Message.success(null).add(checkTypeMapper.selectAll());
    }

    @Override
    public Message<List<CheckType>> selectById(String checkTypeId) {
        return Message.success(null).add(checkTypeMapper.selectById(checkTypeId));
    }

    @Override
    public Message<List<CheckType>> selectByCAId(String checkAttendanceId) {
        return Message.success(null).add(checkTypeMapper.selectByCAId(checkAttendanceId));
    }
}
